package com.qf.rabbitmqcase.consumer;

import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.io.IOException;

/**
 * @author 刘欣
 * @createTime 2023/3/3 14:50
 * @description
 */
@Component
@Slf4j
public class MyConsumer {

    /**
     * 消费死信队列消息
     *
     * @param msg
     * @param channel
     * @param message
     */
    @RabbitListener(queues = "dead_queue")
    public void getMsg(String msg, Channel channel, Message message) throws IOException {
        log.debug("msg={},channel={},message={}", msg, channel, message);
        channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
    }
}
